/*

BlackRabbit - OpenSource IDE.
@author Edward Sarkisyan (edward.sarkisyan@gmail.com)
Use LGPL (http://www.gnu.org/copyleft/lesser.html)

*/

#include "searchwidget.h"
#include "ui_searchwidget.h"

SearchWidget::SearchWidget(QWidget *parent) :
    QWidget(parent),
    m_ui(new Ui::SearchWidget)
{
    m_ui->setupUi(this);
    //connect(m_ui->searchCombo->lineEdit(), SIGNAL(returnPressed()), this, SLOT(search()));
}

SearchWidget::~SearchWidget()
{
    delete m_ui;
}

void SearchWidget::changeEvent(QEvent *e)
{
    QWidget::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        m_ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void SearchWidget::addSearchVariant(QIcon icon, QString name, QString query)
{
    m_ui->searchCombo->addItem(icon, name, query);
}

void SearchWidget::search()
{
    qDebug(m_ui->searchCombo->currentText().toStdString().c_str());
}

void SearchWidget::on_searchCombo_editTextChanged(QString value)
{
    QString query = m_ui->searchCombo->itemData(m_ui->searchCombo->currentIndex()).toString();
    query.arg(value);
}
